import api from './index'
import axios from 'axios'
import Vue from "vue";
//import store from '../store'
import {NAME,TOKEN} from "@/store/mutations";

/**
 * login func
 * parameter: {
 *     username: '',
 *     password: '',
 *     remember_me: true,
 *     captcha: '12345'
 * }
 * @param parameter
 * @returns {*}
 */
export function login (parameter) {
    return axios({
        url: api.Login,
        method: 'post',
        data: parameter
    })
}
export function getInfo() {
    return axios({
        url: api.GetUser+Vue.ls.get(NAME,''),
        method: 'get',
        headers:{
          'Authorization':'JWT '+Vue.ls.get(TOKEN,'')
        }
    })
}
export function getUserinfo (id) {
    return axios({
        url: api.GetUserinfo+id,
        method: 'get',
    })
}

export function getCode (email) {
    return axios({
        url: api.Getcode,
        method: 'post',
        data:email,

    })
}

export function regUser (parameter) {
    return axios({
        url: api.Reg,
        method: 'post',
        data: parameter,

    })
}

export function changePass (parameter) {
        return axios({
            url: api.ChangePass,
            method: 'post',
            data:parameter,

        })
    }

export function vifCode (parameter) {
    return axios({
        url: api.Vifcode,
        method: 'post',
        data: parameter,

    })
}
    export function modfiyPass (parameter) {
        return axios({
            url: api.ModfiyPass,
            method: 'put',
            data: parameter,

        })
    }

export function sendEmail (parameter) {
    return axios({
        url: api.SendEmail,
        method: 'post',
        data:parameter,

    })
}


